{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0ae88034",
   "metadata": {},
   "source": [
    "| Syntax  |  Description  | Example | Remark\n",
    "| ------------|----------|-----------|---------|\n",
    "| append()   | 将元素x添加至列表尾部| 详细看1. | 先运行前面的代码，注意不要漏掉引号|\n",
    "| insert    |将元素x插入列表中间   |  详细看2. |          |\n",
    "| remove   | 去一个对象值作为唯一参数| 详细参考3. |      |\n",
    "|extend    |取一个对象列表作为唯一参数| 详细参考4. |     |\n",
    " |pop   | 取一个可选的索引值作为参数| 详细参考5.  | 若pop()没有告诉要删除哪个对象，默认删除最后一项 |\n",
    " | len | len内置函数会报告一个对象的大小 | 详细参考6. |     |\n",
    " | clear | 清除列表中所有元素    |详细参考7.  |清除的是所有元素    |\n",
    " | copy | 复制列表中的元素   |详细参考8.  | 运行结果只有一次 |\n",
    " | count  | 检索元素在列表中出现的次数 | 详细参考9. | 结果出现的是names的内容|\n",
    " | sort  | 将列表中的元素进行排序| 详细参考10.  | "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "db4cb012",
   "metadata": {},
   "source": [
    "## 1.append"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ad2c75ef",
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function append:\n",
      "\n",
      "append(object, /) method of builtins.list instance\n",
      "    Append object to the end of the list.\n",
      "\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "['mike', 'mary', 'lucy']"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names = [\"mike\",\"mary\",\"lucy\"]\n",
    "help(names.append)\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "0e25335f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['mike', 'mary', 'lucy', 'jack']"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.append(\"jack\")\n",
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "599caf20",
   "metadata": {},
   "source": [
    "## 2.insert"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "aa94bcbc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function insert:\n",
      "\n",
      "insert(index, object, /) method of builtins.list instance\n",
      "    Insert object before index.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "names = [\"mike\",\"mary\",\"lucy\"]\n",
    "help(names.insert)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "57764661",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['mike', 'lisa', 'lisa', 'lisa', 'mary', 'lucy']"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.insert(3,\"lisa\")\n",
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c24967c2",
   "metadata": {},
   "source": [
    "## 3.remove"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2cf1d795",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function remove:\n",
      "\n",
      "remove(value, /) method of builtins.list instance\n",
      "    Remove first occurrence of value.\n",
      "    \n",
      "    Raises ValueError if the value is not present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "names = [\"mike\",\"mary\",\"lucy\"]\n",
    "help(names.remove)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1862d1b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['mike', 'mary']"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.remove(\"lucy\")\n",
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "589d054e",
   "metadata": {},
   "source": [
    "## 4.extend"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "a7fe12a2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function extend:\n",
      "\n",
      "extend(iterable, /) method of builtins.list instance\n",
      "    Extend list by appending elements from the iterable.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "names = [\"mike\",\"mary\",\"lucy\"]\n",
    "help(names.extend)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "a5e66552",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['mike', 'mary', 'lucy', 3, 4]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.extend([3,4])\n",
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "2b5b01c4",
   "metadata": {},
   "source": [
    "## 5. pop"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "da954b50",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function pop:\n",
      "\n",
      "pop(index=-1, /) method of builtins.list instance\n",
      "    Remove and return item at index (default last).\n",
      "    \n",
      "    Raises IndexError if list is empty or index is out of range.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "names = [\"mike\",\"mary\",\"lucy\"]\n",
    "help(names.pop)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "b70d0110",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['mike', 'mary']"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.pop()\n",
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7a4e05a5",
   "metadata": {},
   "source": [
    "## 6.len"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "02199f25",
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'list' object has no attribute 'len'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_9012/545357276.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0mnames\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;34m\"mike\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"mary\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;34m\"lucy\"\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mhelp\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mnames\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlen\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m: 'list' object has no attribute 'len'"
     ]
    }
   ],
   "source": [
    "names = [\"mike\",\"mary\",\"lucy\"]\n",
    "help(names.len)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "0c4b5917",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "found = []\n",
    "len(found)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cd000a4b",
   "metadata": {},
   "source": [
    "## 7.clear"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "23879478",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function clear:\n",
      "\n",
      "clear() method of builtins.list instance\n",
      "    Remove all items from list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "names = [\"mike\",\"mary\",\"lucy\"]\n",
    "help(names.clear)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "9d794186",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.clear()\n",
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "319486e8",
   "metadata": {},
   "source": [
    "## 8.copy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "69e9f7cb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function copy:\n",
      "\n",
      "copy() method of builtins.list instance\n",
      "    Return a shallow copy of the list.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "names = [\"mike\",\"mary\",\"lucy\"]\n",
    "help(names.copy)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "b4353965",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['mike', 'mary', 'lucy']"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.copy()\n",
    "names"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3af2b62e",
   "metadata": {},
   "source": [
    "## 9.count"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "f7a68ed7",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function count:\n",
      "\n",
      "count(value, /) method of builtins.list instance\n",
      "    Return number of occurrences of value.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "names = [\"mike\",\"mary\",\"lucy\"]\n",
    "help(names.count)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "f8571863",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['mike', 'mary', 'lucy']"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "names.count(7)\n",
    "names"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "963bf32a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function sort:\n",
      "\n",
      "sort(*, key=None, reverse=False) method of builtins.list instance\n",
      "    Sort the list in ascending order and return None.\n",
      "    \n",
      "    The sort is in-place (i.e. the list itself is modified) and stable (i.e. the\n",
      "    order of two equal elements is maintained).\n",
      "    \n",
      "    If a key function is given, apply it once to each list item and sort them,\n",
      "    ascending or descending, according to their function values.\n",
      "    \n",
      "    The reverse flag can be set to sort in descending order.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "names = [\"mike\",\"mary\",\"lucy\"]\n",
    "help(names.sort)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d4737a00",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
